package engine.game;

import engine.game.physicalObjects.concreteObjects.Ball;
import engine.game.physicalObjects.concreteObjects.Floor;
import engine.game.physicalObjects.concreteObjects.Net;
import engine.game.physicalObjects.concreteObjects.Wall;

public class Board {

	
	/* *********************************************************
	 * Attributes
	 * ********************************************************* */
	private Net _net;
	private Wall _leftWall;
	private Wall _rightWall;
	private Floor _leftFloor;
	private Floor _rightFloor;
	private int _middle;
	private Team _leftTeam;
	private Team _rightTeam;
	private Ball _ball;
	
	/* *********************************************************
	 * Constructor(s)
	 * ********************************************************* */
	public Board(int sideWidth){
		_middle = sideWidth;
		_net = new Net(_middle);
		_leftWall = new Wall(0);
		_rightWall = new Wall(_middle+sideWidth);
		_leftFloor = new Floor(0, sideWidth);
		_rightFloor = new Floor(_middle, sideWidth);
	}
	
	/* *********************************************************
	 * Instance Methods
	 * ********************************************************* */
	public void newTurn() {
//steps :
		
//1: move all the players:
		_leftTeam.movePlayers();
		_rightTeam.movePlayers();
//2: move the ball:
		_ball.move();
//3: no 3 for now :-)
	}

	public void refreshPlayersAction() {
		_leftTeam.refreshPlayersAction();
		_rightTeam.refreshPlayersAction();
	}
	
	public void initializeBoard(){
		int yPlayer = _leftTeam.getHeight();
		int yNet = _ball.getHeight();
		int rBall = _ball.getRadius();
		
		_ball.initializeBall(_middle, yNet + rBall + 20);
		_leftTeam.initializePlayers(_middle/2, (int) yPlayer/2);
		_rightTeam.initializePlayers((int) 1.5*_middle, (int) yPlayer/2);
	}
	
}
